package net.thellium.ddiameter.protocol.avp;

import net.thellium.ddiameter.protocol.AVPType;
import net.thellium.ddiameter.protocol.avp.parser.AVPValueParser;
import net.thellium.ddiameter.protocol.avp.parser.AvpDataException;

import com.google.inject.Inject;
import com.google.inject.name.Named;

public class OctetStringAVP extends BaseAVP {
	private static final long serialVersionUID = -3911034018932879751L;
	private String value;
	
	private AVPValueParser parser;
	
	public OctetStringAVP(byte[] bytes) {
		try {
			
			value = (String) parser.parseValue(bytes);
		} catch (AvpDataException e) {
			e.printStackTrace();
		}
	}
	public OctetStringAVP(String value) {
		this.value=value;
	}	
	

	public String getStringValue() {
		return value;
	}

	public AVPType getType() {
		return AVPType.OctetString;
	}

	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	@Override
	public String toString() {
		return "OctetStringAVP [value=" + value + ", getStringifiedValue()="
				+ getStringValue() + ", getType()=" + getType()
				+ ", getValue()=" + getValue() + ", getCode()=" + getCode()
				+ ", getVendorID()=" + getVendorID() + ", isEncrypted()="
				+ isEncrypted() + ", isMandatory()=" + isMandatory()
				+ ", isVendorSpecific()=" + isVendorSpecific() + "]";
	}
	
	
	@Inject
	public void setParser(@Named("octetStringParser")  AVPValueParser parser) {
		this.parser = parser;
	}
	
	

}
